package com.demo.project.service;

import com.demo.annotation.AutoWired;
import com.demo.annotation.Component;
import com.demo.project.dao.AccountDataServer;
import com.demo.project.entity.Account;

import java.util.Map;

@Component
public class AccountService {
    @AutoWired
    private AccountDataServer dataServer;

    /**
     * 注册账户信息
     * @param account
     * @param password
     * @param accountInfo
     * @return
     */
    public String register(String account, String password, Account accountInfo){
        return dataServer.addAccount(account, password, accountInfo);//返回uid
    }
    public boolean isRepeatAccountNumber(String accountNumber,String password){
        return this.dataServer.isRepeatAccountNumber(accountNumber, password);
    }
    public String getUidByAccountNumber(String accountNumber,String password){
        return this.dataServer.getUidByAccountNumber(accountNumber, password);
    }
    public Account getAccountInfoByUid(String uid){
        return this.dataServer.getAccountInfoByUid(uid);
    }

    /**
     * 注销账户信息
     * @param account
     * @param password
     * @return
     */
    public boolean cancellation(String account,String password){
        return dataServer.deleteAccount(account, password);
    }

    public Map<String,String> getAllAccountIds(){
        return this.dataServer.getAccountIds();
    }
    public Map<String,Account> getAllAccounts(){
        return this.dataServer.getAccountMap();
    }

    public void setDataServer(AccountDataServer dataServer) {
        this.dataServer = dataServer;
    }
    public AccountDataServer getDataServer() {
        return dataServer;
    }
}
